package com.example.administrator.nl.activity.appointment;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.nl.R;
import com.example.administrator.nl.activity.SearchActivity;
import com.example.administrator.nl.base.BaseActivity;
import com.example.administrator.nl.util.ToastUtil;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class AppointmentMessageActivity extends BaseActivity {

    @BindView(R.id.flowlayout)
    TagFlowLayout flowlayout;

    @BindView(R.id.tv_title)
    TextView tv_title;

    @BindView(R.id.iv_finish)
    ImageView iv_finish;

    @BindView(R.id.tv_appointment)
    TextView tv_appointment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void init() {
        tv_title.setText("预约信息");
        gePerjectData();
        flowlayout.setMaxSelectCount(1);
        flowlayout.setAdapter(new TagAdapter<String>(list) {
            @Override
            public View getView(FlowLayout parent, int position, String s) {
                TextView tv = (TextView) LayoutInflater.from(AppointmentMessageActivity.this).inflate(R.layout.label_appointment,
                        null);
                tv.setText(s);
                return tv;
            }
        });

        // 搜索标签点击事件
        flowlayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
            @Override
            public boolean onTagClick(View view, int position, FlowLayout parent) {
                ToastUtil.ToastShort(list.get(position) + "");
                return true;
            }
        });

        iv_finish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        tv_appointment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AppointmentMessageActivity.this, AppointmentProjectActivity.class);
                startActivity(intent);

            }
        });
    }

    @Override
    public int getContentView() {
        return R.layout.activity_appointment_message;
    }

    List<String> list;

    // 热门搜索数据
    public void gePerjectData() {
        list = new ArrayList<>();
        list.add("是阿萨德");
        list.add("是阿");
        list.add("是阿萨德");
    }
}
